package com.ibm.db2oncampus.portal.framework.beans;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.hibernate.type.StringType;

/**
 * 
 * @author Wellington
 *
 */
public class StringCrypt extends StringType {

	private static final long serialVersionUID = 1L;
	
	public StringCrypt() {

	}

	public Object get(ResultSet rs, String name) throws SQLException {
		String crypt = (String)super.get(rs, name);
		try
		{
			//return CryptUtil.decrypt(crypt);
			return crypt;
		}
		catch(Exception e)
		{
			return crypt;
		}
	}

	public void set(PreparedStatement st, Object value, int index) throws SQLException {
		if(value instanceof String)
			//super.set(st, CryptUtil.encrypt((String)value), index);
			super.set(st, value, index);
		else
			throw new IllegalArgumentException();
	}
}